import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  //  {
  //   title: '订单类型ID',
  //   align:"center",
  //   dataIndex: 'billTypeId'
  //  },
   {
    title: '订单类型',
    align:"center",
    sorter: true,
    dataIndex: 'billTypeName'
   },
   {
    title: '订单编号',
    align:"center",
    sorter: true,
    dataIndex: 'billCode'
   },
  //  {
  //   title: '交易币种ID',
  //   align:"center",
  //   dataIndex: 'currencyId'
  //  },
   {
    title: '交易币种',
    align:"center",
    dataIndex: 'currencyName'
   },
   {
    title: '订单日期',
    align:"center",
    sorter: true,
    dataIndex: 'billDate'
   },
   {
    title: '订单状态',
    align:"center",
    dataIndex: 'billStatus',
    customRender: ({ text }) => {
      return render.renderDict(text, 'sale_order_bill_status');
    },
    ifShow:false
   },
  //  {
  //   title: '业务员ID',
  //   align:"center",
  //   dataIndex: 'salesmanId'
  //  },
   {
    title: '业务员',
    align:"center",
    dataIndex: 'salesmanName'
   },
  //  {
  //   title: '客户ID',
  //   align:"center",
  //   dataIndex: 'customerId'
  //  },
   {
    title: '客户',
    align:"center",
    dataIndex: 'customerName'
   },
  //  {
  //   title: '销售部门ID',
  //   align:"center",
  //   dataIndex: 'saleDepartId'
  //  },
   {
    title: '销售部门',
    align:"center",
    dataIndex: 'saleDepartName'
   },
  //  {
  //   title: '接单组织ID',
  //   align:"center",
  //   dataIndex: 'orderOrganizationId'
  //  },
   {
    title: '出货组织',
    align:"center",
    dataIndex: 'shippingOrganizationName'
   },
   {
    title: '订单交期',
    align:"center",
    sorter: true,
    dataIndex: 'orderDeliveryDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
  //  {
  //   title: '来源订单ID',
  //   align:"center",
  //   dataIndex: 'srcBillId'
  //  },
  //  {
  //   title: '税组合ID',
  //   align:"center",
  //   dataIndex: 'taxCombinationId'
  //  },
   {
    title: '税组合',
    align:"center",
    dataIndex: 'taxCombinationName'
   },
   {
    title: '贸易方式',
    align:"center",
    dataIndex: 'tradeMode',
    customRender: ({ text }) => {
      return render.renderDict(text, 'sale_order_trade_mode');
    },
   },
   {
    title: '价格含税',
    align:"center",
    dataIndex: 'priceIncludesTax',
    customRender: ({ text }) => {
      return render.renderDict(text, 'sale_order_priceIncludes_tax');
    },
   },
   {
    title: '未税金额',
    align:"center",
    sorter: true,
    dataIndex: 'amountNotTaxed'
   },
   {
    title: '税额',
    align:"center",
    sorter: true,
    dataIndex: 'tax'
   },
   {
    title: '价税合计',
    align:"center",
    sorter: true,
    dataIndex: 'totalPriceTax'
   },
  //  {
  //   title: '付款条件ID',
  //   align:"center",
  //   dataIndex: 'paymentConditionId'
  //  },
   {
    title: '付款条件',
    align:"center",
    dataIndex: 'paymentConditionName'
   },
  //  {
  //   title: '立账条件ID',
  //   align:"center",
  //   dataIndex: 'accountConditionId'
  //  },
   {
    title: '立账条件',
    align:"center",
    dataIndex: 'accountConditionName'
   },
  //  {
  //   title: '出货原则ID',
  //   align:"center",
  //   dataIndex: 'shippingPrincipleId'
  //  },
   {
    title: '出货原则',
    align:"center",
    dataIndex: 'shippingPrincipleName'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '第三方编码',
    align:"center",
    dataIndex: 'thirdPartyCode',
    ifShow: false
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "订单类型",
      field: "billTypeName",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "订单编号",
      field: "billCode",
      component: 'Input',
      vagueSearch: true,
      colProps: {span: 6},
 	},
	{
      label: "订单日期",
      field: "billDate",
      component: 'DatePicker',
      componentProps: {
         showTime:true,
         valueFormat: 'YYYY-MM-DD HH:mm:ss'
       },
      colProps: {span: 6},
 	},
	{
      label: "业务员",
      field: "salesmanName",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "客户",
      field: "customerName",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "销售部门",
      field: "saleDepartName",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "订单交期",
      field: "orderDeliveryDate",
      component: 'DatePicker',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '订单类型ID',
    field: 'billTypeId',
    component: 'Input',
    show:false
  },
  {
    label: '订单类型',
    field: 'billTypeName',
    component: 'Input',
    slot:'billTypeSlot',
    dynamicRules: () => {
      return [
        { required: true, message: '请选择订单类型!' },
      ];
    },
  },
  {
    label: '订单编号',
    field: 'billCode',
    component: 'Input',
  },
  {
    label: '交易币种ID',
    field: 'currencyId',
    component: 'Input',
    show:false
  },
  {
    label: '交易币种',
    field: 'currencyName',
    component: 'Input',
    slot: 'currencySlot',
  },
  {
    label: '订单日期',
    field: 'billDate',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '订单状态',
    field: 'billStatus',
    component: 'JDictSelectTag',
    defaultValue:1,
    componentProps:{
        dictCode:"sale_order_bill_status",
        stringToNumber: true,
    },
    ifShow:false
  },
  {
    label: '业务员ID',
    field: 'salesmanId',
    component: 'Input',
    show:false
  },
  {
    label: '业务员',
    field: 'salesmanId',
    component: 'JSelectUserByDept',
    componentProps: {
      isRadioSelection:true,
      rowKey: 'id',
      labelKey: 'realname',
      showButton:false
    },
  },
  {
    label: '客户ID',
    field: 'customerId',
    component: 'Input',
    show:false
  },
  {
    label: '客户',
    field: 'customerName',
    component: 'Input',
    slot: 'customerSlot',
  },
  {
    label: '销售部门ID',
    field: 'saleDepartId',
    component: 'InputNumber',
    show:false
  },
  {
    label: '销售部门',
    field: 'saleDepartId',
    component: 'JSelectDept',
    componentProps: ({}) => {
      return {
        multiple: false,
        showButton: false,
        checkable: false
      }
    },
  },
  {
    label: '储存地点ID',
    field: 'warehouseId',
    component: 'InputNumber',
    show:false
  },
  {
    label: '储存地点',
    field: 'warehouseName',
    component: 'Input',
    slot: 'warehouseSlot',
  },
  {
    label: '出货组织ID',
    field: 'shippingOrganizationId',
    component: 'InputNumber',
    show:false
  },
  {
    label: '出货组织',
    field: 'shippingOrganizationName',
    component: 'Input',
    slot: 'organizationSlot',
  },
  {
    label: '订单交期',
    field: 'orderDeliveryDate',
    component: 'DatePicker',
  },
  {
    label: '来源订单ID',
    field: 'srcBillId',
    component: 'InputNumber',
    show:false
  },
  {
    label: '税组合ID',
    field: 'taxCombinationId',
    component: 'Input',
    show:false
  },
  {
    label: '税组合',
    field: 'taxCombinationName',
    component: 'Input',
  },
  {
    label: '贸易方式',
    field: 'tradeMode',
    component: 'JDictSelectTag',
    defaultValue:0,
    componentProps:{
        dictCode:"sale_order_trade_mode",
        stringToNumber: true,
     },
  },
  {
    label: '价格含税',
    field: 'priceIncludesTax',
    component: 'JDictSelectTag',
    defaultValue:0,
    componentProps:{
        dictCode:"sale_order_priceIncludes_tax",
        stringToNumber: true,
     },
  },
  {
    label: '未税金额',
    field: 'amountNotTaxed',
    component: 'InputNumber',
  },
  {
    label: '税额',
    field: 'tax',
    component: 'InputNumber',
  },
  {
    label: '价税合计',
    field: 'totalPriceTax',
    component: 'InputNumber',
  },
  {
    label: '付款条件ID',
    field: 'paymentConditionId',
    component: 'Input',
    show:false
  },
  {
    label: '付款条件',
    field: 'paymentConditionName',
    component: 'Input',
    slot: 'paymentConditionSlot',
  },
  {
    label: '立账条件ID',
    field: 'accountConditionId',
    component: 'Input',
    show:false
  },
  {
    label: '立账条件',
    field: 'accountConditionName',
    component: 'Input',
    slot: 'accountConditionSlot',
  },
  {
    label: '出货原则ID',
    field: 'shippingPrincipleId',
    component: 'Input',
    show:false
  },
  {
    label: '出货原则',
    field: 'shippingPrincipleName',
    component: 'Input',
    slot: 'shippingPrincipleSlot',
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
    ifShow: false
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const busSaleOrderItemColumns: JVxeColumn[] = [
    {
      title: '销售订单ID',
      key: 'saleOrderId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '料品ID',
      key: 'materialId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    // {
    //   title: '料品编号',
    //   key: 'materialCode',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '料品',
      key: 'materialName',
      type: JVxeTypes.slot,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      slotName: 'action'
    },
    {
      title: '用量',
      key: 'consumption',
      type: JVxeTypes.inputNumber,
      width:"100px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单位ID',
      key: 'unitId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  {
    title: '单位',
    key: 'unitName',
    width: "100px",
    type: JVxeTypes.normal,
    disabled:true
  },
    {
      title: '订单交期',
      key: 'orderDeliveryDate',
      type: JVxeTypes.date,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '定价',
      key: 'fixPrice',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '折扣率',
      key: 'discountRate',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '未税金额',
      key: 'amountNotTaxed',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '税额',
      key: 'tax',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '价税合计',
      key: 'totalPriceTax',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '业务组织ID',
      key: 'businessOrganizationId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '业务组织',
      key: 'businessOrganizationName',
      type: JVxeTypes.slot,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      slotName: 'organizationSlot',
    },
    // {
    //   title: '订单状态',
    //   key: 'itemBillStatus',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '备注',
      key: 'remark',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    // {
    //   title: '删除状态 0正常 1已删除',
    //   key: 'delFlag',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '创建方式 0系统生成',
    //   key: 'createMethod',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '第三方编码',
      key: 'thirdPartyCode',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    // {
    //   title: '组织ID',
    //   key: 'organizationId',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '租户ID',
    //   key: 'tenantId',
    //   type: JVxeTypes.inputNumber,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
  ]


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}